idf_component_register(SRCS "Angry.c" "aaf_usage_example.c" "video_codec_test.c" "main.c"  "util.c"
                    INCLUDE_DIRS "."
                    INCLUDE_DIRS "../root_image/"
                    REQUIRES esp_lcd lvgl fatfs sd_card
                    REQUIRES spiffs
                    REQUIRES spi_flash
                    WHOLE_ARCHIVE)
spiffs_create_partition_image(storage ../spiffs_image FLASH_IN_PROJECT)
# 添加自定义命令来烧录文件
add_custom_target(root_flash
    COMMAND ${ESPTOOLPY} --port ${ESPTOOLPY_PORT} write_flash 0x10000 ${CMAKE_SOURCE_DIR}/root_image/root\(0x4400000\).bin
    COMMENT "Flashing root.bin to ui partition"
    USES_TERMINAL
)

# 确保在烧录时先完成项目构建
add_dependencies(root_flash flash)

if(NOT CONFIG_SOC_SDMMC_HOST_SUPPORTED)
    fail_at_build_time(sdmmc ""
                            "Only ESP32 and ESP32-S3 targets are supported."
                            "Please refer README.md for more details")
endif()